package com.wsoft.system.service.impl;

import cn.hutool.core.convert.Convert;
import com.wsoft.core.service.CommonMemberService;
import com.wsoft.core.vo.MemberVO;
import com.wsoft.system.entity.SysMemberEntity;
import com.wsoft.system.service.ISysMemberService;
import com.wsoft.vo.SysMemberVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author Zhang gukai
 * @Date 2024/11/29 9:05
 */
@Service
public class CommonMemberServiceImpl implements CommonMemberService {
    @Resource
    private ISysMemberService memberService;

    @Override
    public MemberVO getMemberInfo(Long memberId) {
        SysMemberVO member = memberService.getMember(memberId);
        return Convert.convert(MemberVO.class, member);
    }

    @Override
    public List<MemberVO> getMemberList() {
        List<SysMemberEntity> list = memberService.listAll();
        return list.stream().map(item-> Convert.convert(MemberVO.class,item)).collect(Collectors.toList());
    }

    @Override
    public List<MemberVO> getMemberListByName(List<Long> memberIds, String name,String code,String phone) {
        List<SysMemberEntity> list= memberService.hrMemberList(memberIds, name, code ,phone);
        return list.stream().map(item-> Convert.convert(MemberVO.class,item)).collect(Collectors.toList());
    }
}
